NO-JIRA: All CVO manifests in payload should be included#1337
NO-JIRA: All CVO manifests in payload should be included#1337hongkailiu wants to merge 3 commits intoopenshift:mainfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a new test Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@hongkailiu: This pull request explicitly references no jira issue. DetailsIn response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hongkailiu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/payload/render_test.go (1)
67-84: Scan manifests recursively to match the “all manifests” intent.At Line 68,
os.ReadDironly checks the top level of../../install, so nested manifest files would be skipped silently.♻️ Proposed refactor
- installDir := filepath.Join("../../install") - files, err := os.ReadDir(installDir) + installDir := "../../install" + var files []string + err := filepath.Walk(installDir, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if info.IsDir() { + return nil + } + ext := strings.ToLower(filepath.Ext(info.Name())) + if ext == ".yaml" || ext == ".yml" { + files = append(files, path) + } + return nil + }) if err != nil { t.Fatalf("failed to read directory: %v", err) } @@ - for _, manifestFile := range files { - if manifestFile.IsDir() { - continue - } - filePath := filepath.Join(installDir, manifestFile.Name()) + for _, filePath := range files { manifests, err := manifest.ManifestsFromFiles([]string{filePath})🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/payload/render_test.go` around lines 67 - 84, The test reads installDir using os.ReadDir which only lists the top-level entries, so nested manifests under installDir are missed; change the directory traversal to recurse (e.g., use filepath.WalkDir or a recursive os.ReadDir helper) to collect all file paths under installDir before calling manifest.ManifestsFromFiles, then filter files as before into manifestsWithoutIncludeAnnotation using the existing prefix constant ("include.release.openshift.io/"), ensuring you pass the full list of discovered file paths (not just top-level entries) to manifest.ManifestsFromFiles.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/payload/render_test.go`:
- Line 108: The failure message in the t.Fatalf call (t.Fatalf("Those manifests
have no annotation with prefix %q and will not beinstalled by CVO: %s", prefix,
strings.Join(messages, "', '"))) has a typo ("beinstalled") and produces awkward
quoting via strings.Join(messages, "', '"); update the string to "will not be
installed by CVO" and change the join to a readable separator such as
strings.Join(messages, ", ") (or wrap each message in quotes before joining if
quoted output is desired) so the output reads cleanly; the change should be made
where t.Fatalf is invoked and references variables prefix and messages and the
strings.Join call.
---
Nitpick comments:
In `@pkg/payload/render_test.go`:
- Around line 67-84: The test reads installDir using os.ReadDir which only lists
the top-level entries, so nested manifests under installDir are missed; change
the directory traversal to recurse (e.g., use filepath.WalkDir or a recursive
os.ReadDir helper) to collect all file paths under installDir before calling
manifest.ManifestsFromFiles, then filter files as before into
manifestsWithoutIncludeAnnotation using the existing prefix constant
("include.release.openshift.io/"), ensuring you pass the full list of discovered
file paths (not just top-level entries) to manifest.ManifestsFromFiles.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7ee548f7-464a-4daa-97d6-5d95b1260f20
📒 Files selected for processing (1)
pkg/payload/render_test.go
pkg/payload/render_test.go
Outdated
| } | ||
|
|
||
| func Test_cvoManifests(t *testing.T) { | ||
| installDir := filepath.Join("../../install") |
There was a problem hiding this comment.
A small note while I am just passing by. Maybe this is also needed for the bootstrap folder. I would need to check the relevant logic, but it's worth checking.
There was a problem hiding this comment.
9d5717b to
8610704
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/payload/render_test.go (1)
88-103: Use recursive manifest discovery to guarantee full payload coverage.
os.ReadDir(tt.dir)only checks top-level files. If manifests are later placed in nested directories, this test can miss them while still passing. Considerfilepath.WalkDirwith manifest-extension filtering.♻️ Proposed refactor
+import "io/fs" ... - files, err := os.ReadDir(tt.dir) + var files []string + err := filepath.WalkDir(tt.dir, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d.IsDir() { + return nil + } + ext := strings.ToLower(filepath.Ext(path)) + if ext != ".yaml" && ext != ".yml" && ext != ".json" { + return nil + } + files = append(files, path) + return nil + }) if err != nil { t.Fatalf("failed to read directory: %v", err) } if len(files) == 0 { t.Fatalf("no files found in %s", tt.dir) } ... - for _, manifestFile := range files { - if manifestFile.IsDir() { - continue - } - filePath := filepath.Join(tt.dir, manifestFile.Name()) + for _, filePath := range files {Also applies to: 99-103
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/payload/render_test.go` around lines 88 - 103, The test currently uses os.ReadDir(tt.dir) which only reads top-level entries, so replace that with a recursive walk (use filepath.WalkDir starting at tt.dir) to discover manifests in nested directories; inside the WalkDir callback skip directories, filter files by manifest extensions (e.g., .yaml, .yml, .json), build the same list previously populated (manifestsWithoutIncludeAnnotation) and preserve the existing logic that computes include annotation checks using prefix ("include.release.openshift.io/"); apply the same change for the other occurrence noted around lines 99-103 so both checks use recursive discovery and proper error handling in the WalkDir callback.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/payload/render_test.go`:
- Around line 88-103: The test currently uses os.ReadDir(tt.dir) which only
reads top-level entries, so replace that with a recursive walk (use
filepath.WalkDir starting at tt.dir) to discover manifests in nested
directories; inside the WalkDir callback skip directories, filter files by
manifest extensions (e.g., .yaml, .yml, .json), build the same list previously
populated (manifestsWithoutIncludeAnnotation) and preserve the existing logic
that computes include annotation checks using prefix
("include.release.openshift.io/"); apply the same change for the other
occurrence noted around lines 99-103 so both checks use recursive discovery and
proper error handling in the WalkDir callback.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9c077e32-6dc9-4d0a-b033-8f4869543795
📒 Files selected for processing (1)
pkg/payload/render_test.go
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/payload/render_test.go (1)
88-103: Use recursive traversal so this test truly covers all payload manifests.
os.ReadDironly checks one directory level, and Line 100 skips subdirectories entirely. If manifests are later placed in nested folders, they won’t be validated.♻️ Proposed refactor
import ( "bytes" "fmt" + "io/fs" "os" "path/filepath" "strings" "testing" @@ - files, err := os.ReadDir(tt.dir) - if err != nil { - t.Fatalf("failed to read directory: %v", err) - } - - if len(files) == 0 { - t.Fatalf("no files found in %s", tt.dir) - } - var manifestsWithoutIncludeAnnotation []manifest.Manifest const prefix = "include.release.openshift.io/" - for _, manifestFile := range files { - if manifestFile.IsDir() { - continue - } - filePath := filepath.Join(tt.dir, manifestFile.Name()) - data, err := os.ReadFile(filePath) - if err != nil { - t.Fatalf("failed to read manifest file: %v", err) - } - data, err = renderManifest(config, data) - if err != nil { - t.Fatalf("failed to render manifest: %v", err) - } - manifests, err := manifest.ParseManifests(bytes.NewReader(data)) - if err != nil { - t.Fatalf("failed to load manifests: %v", err) - } - - for _, m := range manifests { - m.OriginalFilename = filePath - var found bool - for k := range m.Obj.GetAnnotations() { - if strings.HasPrefix(k, prefix) { - found = true - break - } - } - if !found { - manifestsWithoutIncludeAnnotation = append(manifestsWithoutIncludeAnnotation, m) - } - } - } + err := filepath.WalkDir(tt.dir, func(filePath string, d fs.DirEntry, walkErr error) error { + if walkErr != nil { + return walkErr + } + if d.IsDir() { + return nil + } + data, err := os.ReadFile(filePath) + if err != nil { + return fmt.Errorf("read manifest file %s: %w", filePath, err) + } + data, err = renderManifest(config, data) + if err != nil { + return fmt.Errorf("render manifest %s: %w", filePath, err) + } + manifests, err := manifest.ParseManifests(bytes.NewReader(data)) + if err != nil { + return fmt.Errorf("load manifests from %s: %w", filePath, err) + } + for _, m := range manifests { + m.OriginalFilename = filePath + var found bool + for k := range m.Obj.GetAnnotations() { + if strings.HasPrefix(k, prefix) { + found = true + break + } + } + if !found { + manifestsWithoutIncludeAnnotation = append(manifestsWithoutIncludeAnnotation, m) + } + } + return nil + }) + if err != nil { + t.Fatalf("failed manifest scan for %s: %v", tt.dir, err) + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/payload/render_test.go` around lines 88 - 103, The test currently uses os.ReadDir on tt.dir and skips subdirectories (manifestFile.IsDir()), so nested manifests are ignored; replace the non-recursive loop with a recursive traversal (e.g., filepath.WalkDir) starting at tt.dir, skip directory entries inside the WalkDirFunc, and for each file build the full path (similar to filePath := filepath.Join(...)) and run the same manifest parsing/annotation checks that populate manifestsWithoutIncludeAnnotation using the same const prefix = "include.release.openshift.io/"; ensure symlinks or non-regular files are handled consistently with the original behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/payload/render_test.go`:
- Around line 88-103: The test currently uses os.ReadDir on tt.dir and skips
subdirectories (manifestFile.IsDir()), so nested manifests are ignored; replace
the non-recursive loop with a recursive traversal (e.g., filepath.WalkDir)
starting at tt.dir, skip directory entries inside the WalkDirFunc, and for each
file build the full path (similar to filePath := filepath.Join(...)) and run the
same manifest parsing/annotation checks that populate
manifestsWithoutIncludeAnnotation using the same const prefix =
"include.release.openshift.io/"; ensure symlinks or non-regular files are
handled consistently with the original behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cf01a442-d51b-4963-8b27-88be2f9c57ad
📒 Files selected for processing (1)
pkg/payload/render_test.go
|
/retest-required |
1 similar comment
|
/retest-required |
|
/test e2e-agnostic-ovn-techpreview-serial-2of3 |
|
/testwith openshift/cluster-version-operator/main/e2e-agnostic-ovn-techpreview-serial openshift/oc#2170 |
|
@hongkailiu, |
|
/testwith openshift/cluster-version-operator/main/e2e-agnostic-ovn-techpreview-serial openshift/oc#2170 |
Because `bootstrap-pod.yaml` is not a valid yaml [1], we have to render it and then parse out manifests from it. We could make it valid as we did for the others, but it might be dangerous to do so. We have only one manifest for bootstrap. I am fine with a rendering step. openshift#1171 (comment)
8610704 to
8fefb19
Compare
|
/testwith openshift/cluster-version-operator/main/e2e-agnostic-ovn-techpreview-serial openshift/oc#2170 |
|
/retest |
8fefb19 to
c5a222b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/payload/render_test.go`:
- Around line 332-347: The test currently reads only top-level entries from
tt.dir using os.ReadDir and skips directories (manifestFile.IsDir()), so nested
manifests are missed; update the logic that builds
manifestsWithoutIncludeAnnotation to recursively walk tt.dir (e.g., using
filepath.WalkDir) and collect regular files (filtering for manifest file types
like .yaml/.yml/.json or using manifest.Parse) instead of skipping directories,
then open and validate each discovered file (use the same variable names:
tt.dir, manifestFile/filePath, manifestsWithoutIncludeAnnotation, and prefix) so
nested manifests are included in the validation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 441c9f1b-b7e2-48fb-896c-799b8cc3a342
📒 Files selected for processing (1)
pkg/payload/render_test.go
| files, err := os.ReadDir(tt.dir) | ||
| if err != nil { | ||
| t.Fatalf("failed to read directory: %v", err) | ||
| } | ||
|
|
||
| if len(files) == 0 { | ||
| t.Fatalf("no files found in %s", tt.dir) | ||
| } | ||
|
|
||
| var manifestsWithoutIncludeAnnotation []manifest.Manifest | ||
| const prefix = "include.release.openshift.io/" | ||
| for _, manifestFile := range files { | ||
| if manifestFile.IsDir() { | ||
| continue | ||
| } | ||
| filePath := filepath.Join(tt.dir, manifestFile.Name()) |
There was a problem hiding this comment.
Top-level-only scan can miss manifests and under-report violations.
Line 332 reads only direct entries, and Line 344-Line 346 skips directories entirely. If manifests exist under nested folders, they are never validated, so this test can pass while missing unannotated payload manifests.
🔧 Suggested fix (recursive walk + manifest file filtering)
import (
"bytes"
"fmt"
+ "io/fs"
"os"
"path/filepath"
"strings"
"testing"
@@
- files, err := os.ReadDir(tt.dir)
+ var files []string
+ err := filepath.WalkDir(tt.dir, func(path string, d fs.DirEntry, err error) error {
+ if err != nil {
+ return err
+ }
+ if d.IsDir() {
+ return nil
+ }
+ ext := strings.ToLower(filepath.Ext(d.Name()))
+ if ext != ".yaml" && ext != ".yml" && ext != ".json" {
+ return nil
+ }
+ files = append(files, path)
+ return nil
+ })
if err != nil {
t.Fatalf("failed to read directory: %v", err)
}
@@
- for _, manifestFile := range files {
- if manifestFile.IsDir() {
- continue
- }
- filePath := filepath.Join(tt.dir, manifestFile.Name())
+ for _, filePath := range files {
data, err := os.ReadFile(filePath)
if err != nil {
t.Fatalf("failed to read manifest file: %v", err)
}As per coding guidelines, "**: -Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| files, err := os.ReadDir(tt.dir) | |
| if err != nil { | |
| t.Fatalf("failed to read directory: %v", err) | |
| } | |
| if len(files) == 0 { | |
| t.Fatalf("no files found in %s", tt.dir) | |
| } | |
| var manifestsWithoutIncludeAnnotation []manifest.Manifest | |
| const prefix = "include.release.openshift.io/" | |
| for _, manifestFile := range files { | |
| if manifestFile.IsDir() { | |
| continue | |
| } | |
| filePath := filepath.Join(tt.dir, manifestFile.Name()) | |
| var files []string | |
| err := filepath.WalkDir(tt.dir, func(path string, d fs.DirEntry, err error) error { | |
| if err != nil { | |
| return err | |
| } | |
| if d.IsDir() { | |
| return nil | |
| } | |
| ext := strings.ToLower(filepath.Ext(d.Name())) | |
| if ext != ".yaml" && ext != ".yml" && ext != ".json" { | |
| return nil | |
| } | |
| files = append(files, path) | |
| return nil | |
| }) | |
| if err != nil { | |
| t.Fatalf("failed to read directory: %v", err) | |
| } | |
| if len(files) == 0 { | |
| t.Fatalf("no files found in %s", tt.dir) | |
| } | |
| var manifestsWithoutIncludeAnnotation []manifest.Manifest | |
| const prefix = "include.release.openshift.io/" | |
| for _, filePath := range files { | |
| data, err := os.ReadFile(filePath) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@pkg/payload/render_test.go` around lines 332 - 347, The test currently reads
only top-level entries from tt.dir using os.ReadDir and skips directories
(manifestFile.IsDir()), so nested manifests are missed; update the logic that
builds manifestsWithoutIncludeAnnotation to recursively walk tt.dir (e.g., using
filepath.WalkDir) and collect regular files (filtering for manifest file types
like .yaml/.yml/.json or using manifest.Parse) instead of skipping directories,
then open and validate each discovered file (use the same variable names:
tt.dir, manifestFile/filePath, manifestsWithoutIncludeAnnotation, and prefix) so
nested manifests are included in the validation.
|
@hongkailiu: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary by CodeRabbit